
    <div class="content margin_top">
        <header class="header fixed_top bg_mx_green"></header>
        <form class="exception"></form>
    </div>
    <div class="toast"></div>
    <div class="dialog">
        <div class="dialog_body">
            <div class="dialog_header">提示</div>
            <div class="dialog_content">内容</div>
            <input type="text">
        </div>
        <div class="dialog_footer">
            <div class="dialog_btn dialog_cancel">取消</div>
            <div class="dialog_btn dialog_ok">确定</div>
        </div>
    </div>
    <div class="mask all"></div>
    <!-- toast模版 -->
    <script type="text/template" charset="utf-8" id='toast_template'>
        <i class="iconfont icon-toast{{=it.icon}}"></i>
        <div class="toast_text">{{=it.text}}</div>
    </script>
    <script type="text/template" charset="utf-8" id='info_template'>
        <div class="bg_white margin_b_10">
            <div class="flex border_b padding_10_15 border_b">
                <div class="width_100">异常原因</div>
                <div class="width_100 light">
                    <select name="reason">
                        <{foreach from=$exceptionreason key=k item=value }>
                        <option value="<{$value}>"><{$value}></option>
                        <{/foreach}>
                    </select>
                </div>
                <div class="width_200">
                    <input type="text" placeholder="其他原因" name="other_result">
                    <input type="hidden" name="pigid">
                </div>
            </div>
            <div class="text_info padding_10_15">
                <textarea name="descripation" rows="5" placeholder="请输入异常原因描述" request title="异常原因描述"></textarea>
            </div>
        </div>
        <div class="padding_15 font_16">
            <button class="btn btn_mx_green all_width lineheight_3">保存</button>
        </div>

        <input name="_csrf" type="hidden" id="_csrf" value="<{$app->request->csrfToken}>">
    </script>
    <script>
        // 页面初始化
            var evalinfo = doT.template($("#info_template").text());
            var evalToast = doT.template($("#toast_template").text());
            loaddata(".exception",evalinfo);
            loadheadbar("异常处理",1)
        // 提交表单
            var submited = false;
            $(".exception").submit(function(e){
                e.preventDefault();
                var pigid = GetQueryString("pigid");
                $("input[name=pigid]").val(pigid)
                with(this){
                    for (var i = 0; i < this.length; i++) {
                        if($(this[i]).attr("request")==""){
                            if(!checkone(this[i])){
                                return false;
                            }
                        }
                    }
                    if(submited){
                        return false;
                    }else{
                        $(".mask").show()
                        $(".dialog").fadeIn().find(".dialog_content").show().html("确定提交吗？");
                    }
                }
            })
            $(".dialog_cancel").click(function(){
                $(".mask,.dialog,.dialog .dialog_content,.dialog input").fadeOut(400)
            })
            $(".dialog_ok").click(function(){
                $(".mask,.dialog,.dialog .dialog_content,.dialog input").fadeOut(400);
                var data = $(".exception").serialize();
                $.post("/business/person/post-pig-exception",data,function(res){console.log(res)
                    submited = true;
                    toast("attention",res.msg)
                    if(!res.status){
                        location.href='/business/person/pig';
                    }
                },"json")
            })
    </script>